package cn.yi.newsys.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yi.newsys.pojo.User;
import cn.yi.newsys.service.UserService;
import cn.yi.newsys.service.impl.UserServiceImpl;

public class ExistsUserEmailServlet extends HttpServlet {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response) ;
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		// 获取请求数据
		String temp = request.getParameter("useremail") ;
		// 创建用户业务逻辑对象
		UserService us = new UserServiceImpl() ;
		boolean flag = us.checkUserEmailExists(temp) ;
		if(flag){
			out.print("0") ;
		}else{
			out.print("1") ;
		}
		out.flush();
		out.close();
	}

}
